home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Space & Astronomy
/
Space and Astronomy (October 1993).iso
/
mac
/
VIEWERS
/
MSDOS
/
STRIPGIF.ZIP
/
STRIPGIF.C
next >
Wrap
C/C++ Source or Header
|
1988-02-27
|
1KB
|
64 lines
/*****************************************************************************
* *
* Program to remove yecchy stuff before GIF header *
* *
*****************************************************************************/
#include <stdio.h>
main(ac,av)
int ac;
char *av[];
{
static char id[] = "GIF87a"; /* GIF header string to look for */
char *cp;
int c;
FILE *fp1,*fp2,*fopen();
/** Verify command line parameters **/
if (ac<3) {
printf("Usage is STRIPGIF infile outfile\n");
exit(1);
}
/** Attempt to open "infile" **/
fp1=fopen(av[1],"rb");
if (!fp1) {
printf("Unable to open %s\n",av[1]);
exit(1);
}
/** Search for GIF header **/
cp=id;
while ((c=getc(fp1))>=0) {
if (c==*cp) {
cp++;
if (!(*cp)) break;
} else cp=id;
}
/** If header was not found then print error message **/
if (c<0) {
printf("No valid GIF file found!\n");
fclose(fp1);
exit(1);
}
/** Otherwise copy header and rest of infile to outfile **/
fp2=fopen(av[2],"wb");
if (!fp2) {
printf("Unable to create %s\n",av[2]);
fclose(fp1);
exit(1);
}
fprintf(fp2,"%s",id);
while ((c=getc(fp1))>=0) putc(c,fp2);
fclose(fp2);
fclose(fp1);
}